package org.ycy.data.generator.generator;

import cn.hutool.core.util.RandomUtil;
import org.ycy.data.generator.constants.Symbol;
import org.ycy.data.generator.entity.StringCheckInfo;
import org.ycy.data.generator.utils.ChineseUtil;

/**
 * @ClassName StringRandomGenerator
 * @Description 字符串随机生成器
 * @Author 原长友
 * @Date 2023/5/20 23:22
 * @Version 1.0
 **/
public class StringRandomGenerator extends IGenerator<StringCheckInfo> {

    @Override
    public Object generator() {

        Integer length = checkInfo.getLength();
        String checkString;
        switch (checkInfo.getLanguageType()) {
            case Number:
                checkString = Symbol.numberString;
                break;
            case English:
                checkString = Symbol.letters;
                break;
            case Chinese:
                return ChineseUtil.getRandomChinese(length);
            default:
                return RandomUtil.randomString(length);
        }
        if (checkString == null) {
            return RandomUtil.randomString(length);
        }
        return RandomUtil.randomString(checkString, length);
    }
}
